<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {include file="/layout/scriptload"}
    <title>修改资料</title>
</head>
<body>
<div class="box">
    <!-- /.box-header -->
    <section class="content">
    <div class="box-body">
        <form role="form">
            <div class="form-group col-md-7" >
                <label>账号昵称<span style="font-size: 18px;color: red">*</span></label>
                <input type="text" id="name" class="form-control" value="{$list.username}">
            </div>
            <div class="form-group col-md-7" >
                <label>登录账号 <span style="font-size: 18px;color: red">*</span></label>
                <input type="text" class="form-control layui-input" value="{$list.loginid}" id="loginid">
            </div>
            <div class="form-group col-md-7" >
                <label>登录密码<span style="font-size: 18px;color: red">*</span></label>
                <input type="password" id="pwd" class="form-control" placeholder="请输入密码" value="">
            </div>
            <div class="form-group col-md-7" >
                <label>确认密码<span style="font-size: 18px;color: red">*</span></label>
                <input type="password" id="repwd" class="form-control" placeholder="请确认密码" value="">
            </div>
            <input type="hidden" id="aid" value="{$list.id}">
            <div class="form-group col-md-7" >
                <div id="btn_save" class="btn btn-info pull-right">保存</div>
            </div>
        </form>
    </div>
    <!-- /.box-body -->
    </section>
</div>
</body>
<script>
    $(function(){
        $('#btn_save').click(function () {
            var _id = $('#aid').val();
            var _name = $('#name').val();
            var _loginid = $('#loginid').val();
            var _pwd = $('#pwd').val();
            var _repwd = $('#repwd').val();
            if(_name == ''){
                layerAlert('请输入昵称');
                return false;
            }
            if(_loginid == ''){
                layerAlert('请输入登录账号');
                return false;
            }
            if(_pwd == ''){
                layerAlert('登录密码不能为空');
                return false;
            }
            if(_pwd !== _repwd){
                layerAlert('两次密码输入不一样');
                return false;
            }
            $.ajax({
                type: 'post',
                cache: false,
                url: '{:url("admin/adminindex/doEditInfo")}',
                data: {id:_id,name:_name,loginid:_loginid,pwd:_pwd},
                success: function(data) {
                    if(data.code=="0")
                    {
                        layerAlert('修改成功',function(){
                            parent.window.location.reload();
                            layerParentClose();
                        });
                    }else{
                        layerAlert('修改失败');
                    }
                }
            })
        })
    })
</script>
</html>